
{extend name='public/base' /}

{block name="content"}

<div class="layui-col-md12">

    <div class="layui-card">
        <div class="layui-card-header" style="line-height: 55px;">
            <div class="layui-btn-container do_btn">
                <!--按钮区-->
                <button class="layui-btn layui-btn-sm" data-type="add"><i class="layui-icon"></i>添加关键词回复</button>

            </div>
        </div>
        <div class="layui-card-body">

            <div class="layui-tab layui-tab-brief" lay-filter="lemo-brief">
                <ul class="layui-tab-title">
                    {volist name="typeList" id="vo"}
                    <li {if $vo.type== $type } class="layui-this" {/if}><a href="{$vo.url}">{$vo.item}</a></li>
                    {/volist}
                </ul>
                <div class="layui-tab-content" style="height: auto;">
                    <div class="layui-tab-item layui-show">

                        <table class="layui-table" id="list" lay-filter="list"></table>

                    </div>

                </div>
            </div>


        </div>
    </div>

</div>


{/block}


{block name="js"} <!--js处理区-->


<script type="text/html" id="action">
    {:widget('common/forms/Editbtn',array('编辑回复'))}

  <!--  <a href="{:url('replyEdit')}?id={{d.id}}" class="layui-btn  layui-btn-xs" lay-event="edit">{:lang('edit')}</a>-->
    {{# if(d.type=='keyword') { }}
    {:widget('common/forms/Delbtn',array('删除回复',2))}
    {{# } }}
</script>


<script type="text/html" id="create_time">
    {{layui.util.toDateString(d.create_time*1000, 'yyyy-MM-dd HH:mm:ss')}}
</script>
<script type="text/html" id="update_time">
    {{layui.util.toDateString(d.update_time*1000, 'yyyy-MM-dd HH:mm:ss')}}
</script>


<script>
    layui.use(['form', 'table','element','lucky'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            element = layui.element;
        var lucky=layui.lucky;
        var info = {:json_encode($info)};
        var t="{$type}";
        var tableIn = table.render({
            elem: '#list',
            data:info,
            id:'table_id',
            cols: [[
                {field: 'id', title: 'ID', width: 80, sort: true},
                {field: 'keyword', title: '关键字', width: 120,},
                {field: 'type', title: '事件类型', width: 120,},
                {field: 'msg_type', title: '回复消息类型 ', width: 120, },
                {field: 'data', title: '文本回复内容', width: 120, },
                {field: 'material_id', title: '媒体id', width: 120,},
                {field: 'create_time', title: '添加时间', width: 180,templet:'#create_time'},
                {field: 'update_time', title: '更新时间', width: 180,templet:'#update_time'},
                {title:'操作',width:120, toolbar: '#action',align:"center"},
            ]],

        });


        table.on('tool(list)', function (obj) {
            var data = obj.data;
            var _id=parseInt(data.id);
            var layEvent = obj.event;
            if(layEvent==="del"){
                lucky.Form_Confirm("{:url('replyDel')}",{id:_id},"确认删除回复？","POST","table_id");
                return false;
            }else {
                var u="{:url('replyEdit')}?id="+_id;
                lucky.CreateForm("编辑回复","80%","90%",u,'table_id');
                return  false;
            }
        });



        var active = {
            add:function(){
                lucky.CreateForm("添加回复","80%","90%",'{:url("replyAdd")}?type='+t,'table_id');
                return false;
            },
            reload: function(){
                lucky.CreateReload("table_id");
            }
        };

        $('.do_btn .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });


    });


</script>

{/block}